package com.coco.action;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.coco.base.BaseServlet;
import com.coco.model.News;
import com.google.gson.Gson;

/**
 * Servlet implementation class NewsServlet
 */
public class NewsServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
       
	protected void initNews(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
		response.setContentType("text/json;charset=utf-8");
		List<News> list = newsServiceImpl.findAllNews();
		Gson gson = new Gson();
		response.getWriter().write(gson.toJson(list));
	}

}
